import struct

# 打开文件
with open('path/to/train-images-idx3-ubyte', 'rb') as f:
    # 读取前16个字节的数据
    file_header = f.read(16)

# 定义文件头的格式
file_header_format = '>IIII'

# 解析文件头
magic_number, num_images, num_rows, num_cols = struct.unpack(file_header_format, file_header)

print("Magic Number:", magic_number)
print("Number of Images:", num_images)
print("Number of Rows:", num_rows)
print("Number of Columns:", num_cols)
